import { reqBanner, reqCategory, reqFloor } from "@/api";

const state = {
  list: [],
  bannerList: [],
  floorList: [],
};
const mutations = {
  GETLIST(state, data) {
    state.list = data;
  },
  GETBANNER(state, data) {
    state.bannerList = data;
  },
  GETFLOOR(state, data) {
    state.floorList = data;
  },
};
const actions = {
  async getList({ state, commit, dispatch }) {
    let res = await reqCategory();
    if (res.code === 200) {
      commit("GETLIST", res.data);
    } else {
      alert("出错了");
    }
  },
  async getbanner({ state, commit, dispatch }) {
    let res = await reqBanner();
    if (res.code === 200) {
      commit("GETBANNER", res.data);
    } else {
      alert("出错了");
    }
  },
  async getfloor({ state, commit, dispatch }) {
    let res = await reqFloor();
    if (res.code === 200) {
      commit("GETFLOOR", res.data);
    }
  },
};

export default { namespaced: true, state, mutations, actions };
